package design.mode.effective_java.chapter4.item20;



import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 骨架实现类
 *
 * @author ZhongMingde on 2021/8/14
 */

public abstract class AbstractMapEntry<K, V> implements Map.Entry<K, V> {

    @Override
    public V setValue(V value){
        throw new UnsupportedOperationException();
    }

    @Override
    public boolean equals(Object o){
        if (o == this){
            return true;
        }
        if(!(o instanceof Map.Entry)){
            return false;
        }
        Map.Entry<?,?> e = (Map.Entry<?, ?>) o;
        return Objects.equals(e.getKey(),getKey()) && Objects.equals(e.getValue(),getValue());
    }

    @Override public String toString() {
        return getKey() + "=" + getValue();
    }

    @Override public int hashCode() {
        return Objects.hashCode(getKey())^ Objects.hashCode(getValue());
    }

    public static void main(String[] args) {

    }
}
